package com.xieyingwangluo.yxpart.logic;

import com.xieyingwangluo.yxpart.bean.Result;
import com.xieyingwangluo.yxpart.entity.PowerModel;
import com.xieyingwangluo.yxpart.service.PowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Component
public class PowerLogic {
    @Autowired
    private PowerService powerService;

    //添加权限
    public Result add(
                      /*@RequestParam("inface") String inface,
                      @RequestParam("customer_type") int customer_type,
                      @RequestParam("type") int type*/
                      PowerModel powerModel
    ) {
        powerService.add(powerModel);
        return Result.generate(0, "Add success", powerModel);
    }

    //修改权限
    public Result upd(
                      /*@RequestParam("inface") String inface,
                      @RequestParam("customer_type") int customer_type,
                      @RequestParam("type") int type*/
            PowerModel powerModel
    ) {
        powerService.update(powerModel);
        return Result.generate(0, "Update success", powerModel);
    }

    //删除权限
    public Result del(
                      @RequestParam("noid") String noid) {
        powerService.del(noid);
        return Result.generate(0, "Delete success", null);
    }

    //显示权限列表
    public Result selA(
            PowerModel powerModel
    ) {
       List<PowerModel> list =  powerService.selA(powerModel);
        return Result.generate(0, "查询成功", list);
    }

    //显示权限信息(单条)
    public Result selO(
                       @RequestParam("noid") String noid) {
        powerService.selO(noid);
        return Result.generate(0, "查询成功", null);
    }
}
